package org.bbl.db.mybatis.mapper;

import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.session.RowBounds;
import org.bbl.db.domain.BblId;
import org.bbl.db.domain.SearchResult;

import java.util.List;

/**
 * @author biniamg
 * @since 2/8/13
 */
public interface SearchResultMapper {

    //   param1 = tableName
    // param2 = bookId starts
    //param 3 bookId ends
    //param 4 languageId
    //param 5 keu
    @Select("SELECT v.verseId FROM ${param1} v WHERE " +
            "v.bookid &gt;= #{param2} AND  " +
            "v. bookid &lt;= #{param3} AND " +
            "v.verse like #{param5}")
    List<BblId> search(String param1, int param2, int param3, int param4, String param5, RowBounds rowBounds);

    @Select("SELECT b.shortName, v.* FROM ${param1} v, book b WHERE v.verseId = #{param3} AND b.bookid = v.bookid AND b.languageId = #{param2} ")
    List<SearchResult> findById(String param1, int param2, int param3);


    // @Select("SELECT b.shortName, v.* FROM ${param1} v, book b WHERE FIND_IN_SET ( v.verseId , #{param3} ) <> 0 AND b.bookid = v.bookid AND b.languageId = #{param2}; ")
    //  List<SearchResult> findById(String param1, int param2, String param3);


}
